package components.appearance;

import com.uqbar.vainilla.GameComponent;
import com.uqbar.vainilla.appearances.Animation;
import com.uqbar.vainilla.appearances.Sprite;

public class DestroyAnimation extends Animation {
	
	private GameComponent gc;

	public DestroyAnimation(double meantime, Sprite[] sprites,GameComponent gc) {
		super(meantime, sprites);
		
		this.gc = gc;

	}

	@Override
	protected void advance() {
		this.setCurrentIndex(this.getCurrentIndex() + 1);

		if(this.getCurrentIndex() >= this.getSprites().length) {
			this.setCurrentIndex(this.getSprites().length-1);
			this.gc.destroy();
			
		}

		this.setRemainingTime(this.getMeantime() - this.getRemainingTime());
	}
	
}
